#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include<stdlib.h>
#include<string.h>

typedef struct lnode {
    int data;
    struct lnode* next;
} node;
typedef struct {
    node* head;
    node* rear;
    int size;
} queue;

void Init(queue* q) {
    q->head = NULL;
    q->rear = NULL;
    q->size = 0;
}
void Push(queue* q, int x, int m) {
    if (q->size == m)printf("full\n");
    else {
        q->size++;
        node* cur = (node*)malloc(sizeof(node));
        if (cur == NULL) EXIT_FAILURE;
        cur->data = x;
        cur->next = NULL;
        if (q->head == NULL) {
            q->head = q->rear = cur;
            cur->next = cur;
        }
        else {
            q->rear->next = cur;
            q->rear = cur;
            cur->next = q->head;
        }
    }
}
void Pop(queue* q) {
    if (q->size == 0) {
        printf("empty\n");
    }
    else if (q->size == 1) {
        printf("%d\n", q->head->data);
        q->head = q->rear = NULL;
        q->size--;
    }
    else {
        printf("%d\n", q->head->data);
        node* tmp = q->head;
        q->head = q->head->next;
        free(tmp);
        q->size--;
    }
}
void Front(queue* q) {
    if (q->size == 0) {
        printf("empty\n");
    }
    else {
        printf("%d\n", q->head->data);
    }
}

int main() {
    int n = 0, c = 0, d = 0;
    char str[6];
    queue qu;
    Init(&qu);
    scanf("%d%d", &n, &c);
    for (int i = 0; i < c; i++) {
        scanf("%s", str);
        if (strcmp(str, "push") == 0) {
            scanf("%d", &d);
            Push(&qu, d, n);
        }
        else if (strcmp(str, "pop") == 0) Pop(&qu);
        else if (strcmp(str, "front") == 0) Front(&qu);
    }
    return 0;
}